Add cross-platform Swift package tests for macOS#25344
Add cross-platform Swift package tests for macOS#25344
Conversation
Generated by 🚫 Danger |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
0be8eea to
0eae085
Compare
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 31355 | |
| Version | PR #25344 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | fc94073 | |
| Installation URL | 4qn4l7l512o20 |
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 31355 | |
| Version | PR #25344 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | fc94073 | |
| Installation URL | 4a3l0jqp1n000 |
25024a8 to
dd39a13
Compare
Defines a subset of modules that build and test on macOS without Xcode, enabling `swift test` from the repo root. Modules can be incrementally added here as they become cross-platform. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…o cross-platform package Replace unnecessary UIKit imports with Foundation in Obj-C headers that only use Foundation types. Remove stale UIKit import from FeatureFlagRemote.swift. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dd39a13 to
34fe73f
Compare
Create WordPressSharedObjCUI and WordPressSharedUI for UIKit-dependent code, keeping WordPressSharedObjC and WordPressShared cross-platform. Update all import statements across the codebase accordingly.
Introduce DeviceInformation struct to replace direct UIDevice usage in NotificationSettingsServiceRemote. Use ProcessInfo for OS version in SessionDetails. Guard UIKit-only code with #if canImport(UIKit) in HTTPAuthenticationAlertController, UIDevice+Extensions, NSMutableParagraphStyle+extensions, GravatarServiceRemote (upload), PluginDirectoryEntry (HTML text extraction), and SiteDesignServiceRemote (screen scale). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add WordPressSharedObjC, WordPressShared, WordPressKit, and WordPressSharedTests to the root Package.swift for macOS testing. Fix cross-platform build issues: remove unused MobileCoreServices import from URL+Helpers, guard String.accessibilityLabel usage in Double+Stats with #if canImport(UIKit), and remove unused WordPressSharedObjC import from String+RemovingMatches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Runs `swift test` from the repository root to verify that cross-platform modules build and pass tests on macOS without Xcode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add explicit `as [Target.Dependency]` annotations to the larger dependency arrays. This helps the Swift compiler type-check the Package() expression within its time limit after the addition of WordPressSharedUI and WordPressSharedObjCUI targets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34fe73f to
fc94073
Compare
|
|
There are some great changes to clean up the targets in this PR; however, I'm not completely confident that making
It may still be useful to support |
| import Foundation | ||
| import WordPressShared | ||
|
|
||
| extension ReachabilityUtils { |
There was a problem hiding this comment.
I'd suggest moving those to WordPressUI as opposed to creating a new module WordPressSharedUI.
|
Just to clarify – no questions about targets that are genuinely cross-platform, but I'm not sure how many there are except for |





Summary
Migrating to
swift test(as suggested by @mokagio) for our logic tests has been a goal for a while, but it has to be done incrementally. It turns out it's not too hard to get started (this PR has very few code changes aside from newimportstatements), and as a module is made cross-platform, we just add it to the project's rootPackage.swiftfile and CI will enforce that it stays that way. We can use the same approach for Swift 6 compatibility.There's a ton of other stuff I wanted to do that I left out of this PR like:
swift test)swift testoutputimport UIKitusageInstead, this PR is pretty focused, and just starts us off by:
Package.swiftso modules can be built and tested on macOS withswift test(no Xcode required)WordPressSharedObjCandWordPressSharedinto cross-platform core modules and UIKit-only modules (WordPressSharedObjCUI,WordPressSharedUI)WordPressKitfrom UIKit by introducing aDeviceInformationProviderprotocol (whichUIDeviceconforms to on iOS) and guarding UIKit-only code with#if canImport(UIKit)swift teston every PRCurrently 15+ modules and 53 tests across 7 suites run on macOS. As more modules are made cross-platform, they can be added to the root package.
Test plan
swift testpasses locally with 53 tests in 7 suites🤖 Generated with Claude Code